{include file="public/head"/}
<style type="text/css">
	.layui-table td, .layui-table th {
		position: relative;
		padding: 13px 10px;
		min-height: 19px;
		line-height: 19px;
		font-size: 14px;
	}
	.layadmin-carousel {
		height: 100px !important;
		background-color: #fff;
	}

	.layadmin-backlog-body p cite {
		font-style: normal;
		color: #009688;
		font-size: 16px;
		font-weight: bold;
	}
</style>
<div class="layui-content-wrapper">
	<div class="layui-fluid">
		<div class="layui-row layui-col-space8">

			<!--数据统计开始-->
			<div class="layui-col-md12">
				<div class="layui-card">
					<div class="layui-card-header">数据统计</div>
					<div class="layui-card-body">
						<div class="layui-carousel layadmin-carousel layadmin-backlog">
							<div carousel-item="">
								<ul class="layui-row layui-col-space10">
									<li style="width: 25%" class="layui-col-xs4">
										<a href="javascript:;"class="layadmin-backlog-body">
											<h3>登录总数</h3>
											<p><cite>{$data['count']}</cite>条</p>
										</a>
									</li>
									<li style="width: 25%" class="layui-col-xs4">
										<a href="javascript:;"class="layadmin-backlog-body">
											<h3>今日登录次数</h3>
											<p><cite>{$data['today_count']}</cite>条</p>
										</a>
									</li>
									<li style="width: 25%" class="layui-col-xs4">
										<a href="javascript:;" class="layadmin-backlog-body">
											<h3>最近一周登录</h3>
											<p><cite>{$data['week_count']}</cite>条</p>
										</a>
									</li>
									<li style="width: 25%" class="layui-col-xs4">
										<a href="javascript:;" class="layadmin-backlog-body">
											<h3>最近一月登录</h3>
											<p><cite>{$data['month_count']}</cite>条</p>
										</a>
									</li>
								</ul>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!--数据统计结束-->

			<!--搜索开始-->
			<div class="layui-col-md12">
				<div class="layui-card">
					<div class="layui-card-header">搜索</div>
					<div class="layui-card-body">
						<div class="table-head-btn" style="margin-bottom: 10px;">
							<div class="layui-form">
								<div class="layui-inline">
									<label class="layui-form-label" style="width:auto;">登录开始时间</label>
									<div class="layui-input-inline">
										<input placeholder="开始时间" class="layui-input" name="start_time"
											   id="start_time" AUTOCOMPLETE="off" autocomplete="off"/>
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label" style="width:auto;">登录结束时间</label>
									<div class="layui-input-inline">
										<input placeholder="结束时间" class="layui-input" name="end_time" id="end_time"
											   AUTOCOMPLETE="off" autocomplete="off"/>
									</div>
								</div>
								<button class="layui-btn" data-type="reload">搜索</button>
							</div>
						</div>
						<table class="layui-hide" id="list" lay-filter="list"></table>
					</div>
				</div>
			</div>
			<!--搜索结束-->
		</div>
	</div>
</div>
{include file="public/foot"/}
<script type="text/html" id="bom">
	{{d.bomlimit}}-{{d.toplimit}}
</script>

<script type="text/html" id="status">
	<input type="checkbox" name="status" value="{{d.user_id}}" lay-skin="switch" lay-text="正常|禁用" lay-filter="status" {{ d.status == 1 ? 'checked' : '' }}>
</script>

<!-- 表格操作列 -->
<script type="text/html" id="tbBasicTbBar">
	<a class="layui-btn layui-btn-xs layui-icon layui-icon-set" data-dropdown="#userTbDrop{{d.LAY_INDEX}}" no-shade="true">
		操作
		<i class="layui-icon layui-icon-drop" style="font-size: 12px;margin-right: 0;"></i></a>
	<!-- 下拉菜单 -->
	<ul class="dropdown-menu-nav dropdown-bottom-right layui-hide" id="userTbDrop{{d.LAY_INDEX}}">
		<div class="dropdown-anchor"></div>
		<li><a lay-event="edit"><i class="layui-icon layui-icon-edit"></i>修改资料</a></li>
		<li><a lay-event="edit_money"><i class="layui-icon layui-icon-dollar"></i>资金冲正</a></li>
		<li><a lay-event="log_info"><i class="layui-icon layui-icon-list"></i>资金明细</a></li>
		<li><a lay-event="order_info"><i class="layui-icon layui-icon-tabs"></i>交易明细</a></li>
		<li><a lay-event="bank_info"><i class="layui-icon layui-icon-templeate-1"></i>卡包管理</a></li>
	</ul>
</script>

<script>
	layui.config({
		base: '__LAYDMIN__', {if config('app.app_debug')}version: true{/if}
	}).extend({
		index: 'lib/index' //主入口模块
	}).use(['index', 'table', 'carousel', 'form', 'laydate','dropdown'], function () {
		var $ = layui.$;
		var admin = layui.admin;
		var table = layui.table;
		var element = layui.element;
		var form = layui.form;
		var util = layui.util;
		var upload = layui.upload;
		var carousel = layui.carousel;
		var device = layui.device();
		var laydate = layui.laydate;
		var dropdown=layui.dropdown;
		var tableLoadDiv = window.top.layer.load(0,{shade:[0.5, '#000']}); //加载层,table.render完成时需要关闭
		//全部数据
		tableIn = table.render({
			elem: '#list',
			url: '{:url(SYS_PATH."/".CONTROLLER."/loginlog",['u_id'=>$u_id])}',
			method: 'post',
			autoSort: false,
			loading: true,
			cols: [[
				{type: 'checkbox', fixed: true},
				{field: 'user_loginlog_id', align: 'center',title: 'ID', width: 90, fixed: true,sort:true},
				{field: 'username', align: 'center',title: '昵称', width: 120},
				{field: 'username', align: 'center',title: '用户名', width: 130},
				{field: 'mobile', align: 'center',title: '手机号码', width: 140},
				{field: 'login_ip', align: 'center',title: '登录ip', width: 160},
				{field: 'login_time', title: '登录时间', width: 160,sort:true,align:'center',
					templet: function(d){
					return util.toDateString(d.login_time*1000,'yyyy-MM-dd HH:mm');
					}
				}
			]],
		page: true,
		done:function (res) {
			window.top.layer.close(tableLoadDiv);
		}
	});


	table.on('sort(list)', function (obj) {
		table.reload('list', {
			initSort: obj //记录初始排序，如果不设的话，将无法标记表头的排序状态。
			, where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
				sort_by: obj.field //排序字段
				, sort_order: obj.type //排序方式
			}
		});
	});

	// 会员组
	form.on('select(user_group_id)', function(data){
		var user_group_id = data.value;
		//执行重载
		table.reload('list', {
			page: {curr: 1 },
			where: {
				user_group_id:user_group_id
			}
		});
	});

	//列表编缉与删除---监听工具条
	table.on('tool(list)', function (obj) {
		var data = obj.data;
		var user_id = data.user_id;
		if (obj.event === 'edit_money') {
			// 修改余额
			layui.layerOpen("{:url(SYS_PATH.'/'.CONTROLLER.'/editMoney')}?user_id="+user_id);
		}else if (obj.event === 'edit') {
			layui.layerOpen("{:url(SYS_PATH.'/'.CONTROLLER.'/edit')}?user_id="+user_id);
		}else if (obj.event === 'log_info') {
			layui.layerOpen("{:url(SYS_PATH.'/'.CONTROLLER.'/logInfo')}?user_id="+user_id);
		}else if (obj.event === 'order_info') {
			layui.layerOpen("{:url(SYS_PATH.'/'.CONTROLLER.'/orderInfo')}?user_id="+user_id);
		}else if (obj.event === 'bank_info') {
			layui.layerOpen("{:url(SYS_PATH.'/'.CONTROLLER.'/bankInfo')}?user_id="+user_id);
		}
	});

	//改变会员状态
	form.on('switch(status)', function (obj) {
		var user_id = this.value;
		var status = obj.elem.checked === true ? 1 : 0;
		admin.req({
			url: '{:url(SYS_PATH.'/'.CONTROLLER.'/doStatus')}'
			, type: 'post'
			, data: {'user_id': user_id, 'status': status}
			, success: function (res) {
				if (res.code==0) {
					window.top.layer.msg(res.msg, {time: 1000, icon: 1,shade:[0.5,'#000']});
				} else {
					if (obj.elem.checked == true) {
						$(obj.elem).prop('checked', false);
					} else {
						$(obj.elem).prop('checked', true);
					}
					form.render();
				}
			}
		});
	});

	// 导出Excel
	$('#addExcel_w').click(function () {
		var start_time = $('#start_time').val();
		var end_time = $('#end_time').val();
		var user_group_id = $('#user_group_id').val();
		var key = $('#key').val();
		var url="{:url(SYS_PATH."/User/exportExcel")}";
		url = url+'?key='+key+'&start_time='+start_time+'&end_time='+end_time+'&user_group_id='+user_group_id;
		window.open(url);
	});

	$('.table-head-btn .layui-btn').on('click', function () {
		var type = $(this).data('type');
		if (type === 'reload') {
			var key = $('#key').val();
			var status = $('#status').val();
			var start_time = $('#start_time').val();
			var end_time = $('#end_time').val();
			if (start_time) {
				if (!end_time) {
					layer.msg('请选择结束时间！');
					return;
				}
			}
			if (end_time) {
				if (!start_time) {
					layer.msg('请选择开始时间！');
					return;
				}
			}
			//执行重载
			table.reload('list', {
				page: {curr: 1 },
				where: {
					key: key,
					status: status,
					end_time: end_time,
					start_time: start_time
				}
			});
		}
	});

	//轮播切换
	$('.layadmin-carousel').each(function () {
		var othis = $(this);
		carousel.render({
			elem: this
			, width: '100%'
			, arrow: 'none'
			, interval: othis.data('interval')
			, autoplay: othis.data('autoplay') === true
			, trigger: (device.ios || device.android) ? 'click' : 'hover'
			, anim: othis.data('anim')
		});
	});
	// 执行一个laydate实例
	laydate.render({
		elem: '#start_time'
		, type: 'datetime'
		, format: 'yyyy-MM-dd HH:mm:ss'//指定元素
	});
	laydate.render({
		elem: '#end_time'
		, type: 'datetime'
		, format: 'yyyy-MM-dd HH:mm:ss'//指定元素
	});
	});
</script>

</body>
</html>

